using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EM.Repository.utility;
using System.Data.SqlClient;

namespace EM.User
{
    public partial class logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Authentication ua = new Authentication();
            ua.CheckSessionAuthentication(Authentication.RedirectionURLTypes.MainPage);

            SetLogoutDate();

        }

        private void SetLogoutDate()
        {
            DbHelper dsrv = new DbHelper();
            SqlCommand cmd = new SqlCommand();
            string sSQL = "";
            sSQL += " UPDATE TBLSESSIONHEADER SET";
            sSQL += "  ENDDATE = GETDATE()";
            sSQL += " WHERE SESSIONHEADERID = @SESSIONHEADERID ";
            cmd.Parameters.Add("@SESSIONHEADERID", SqlDbType.BigInt).Value = Session["SESSIONHEADERID"].ToString();
            cmd.CommandText = sSQL;
            dsrv.ExecuteNonQuery(cmd);

            Session.Abandon();
            Response.Redirect("~/");
        }

    }
}
